ipython 的安装


1. 下载 ipython

pip3 install ipython -i https://pypi.douban.com/simple

2. 使用 ipython

ipython

3. 退出 ipython

exit

jupyter 的安装


1. 下载 jupyter

  • 注意: jupyter 是依赖于 ipython 运行的,所以在下载 jupyter 之前必须先下载 ipython

pip3 install jupyter -i https://pypi.douban.com/simple

2. 设置 jupyter 密码

  • 进入 ipython

ipython

  • 设置密码

from IPython.lib import passwd

passwd()  # 生成密码


3. 配置 jupyter

  • 生成 jupyter 配置文件

jupyter notebook --generate-config --allow-root


  • 进入 jupyter 配置文件

vim /root/.jupyter/jupyter_notebook_config.py

  • 编辑 jupyter 配置文件,去掉需要修改的配置项注释符 “#”

    • jupyter 服务所监听的ip

c.NotebookApp.ip = '0.0.0.0 或 当前Linux的ip'


    • jupyter 服务所监听的端口

c.NotebookApp.port = 8888


    • 是否启动 jupyter 服务后自动打开浏览器

c.NotebookApp.open_browser = False


    • 配置你所设置的加密后密码

c.NotebookApp.password = 'sha1:1addbc02e04d:f37e1d6e93926b380d9e516c6c477af5f5111da2'


3. 启动 jupyter

  • 注意: 如果启动不了很有可能是防火墙的问题

jupyter notebook  --allow-root

# 在浏览器上访问

10.0.0.3:8888

  • 在 jupyter 配置文件中配置了加密密码的情况

    • 直接访问 jupyter 提供的网址使用密码登陆即可



  • 在 jupyter 配置文件中没有配置了加密密码的情况

    • 方式一: 直接使用 jupyter 提供的带 token 的网址进行访问


    • 方式二: 通过 jupyter 启动后提供 token 来登陆 或者 设置新的密码